﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Calc {
	class Program {
		static void Main(string[] args) {
			string expression;
			do {
				Console.Write(">");
				expression = Console.ReadLine( );
				Equation equation = Equation.Create(expression);
				if (equation != null) {
					decimal result;
					string resultExpression;
					if (equation.TryCompute(out result))
						Console.WriteLine(result.ToString( ));
					else if (equation.TryResolve(out resultExpression))
						Console.WriteLine(resultExpression);
				}
			} while (expression != "quit");
		}
	}
}
